<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>班次管理</title>
<meta name="decorator" content="default" />

<script type="text/javascript">
var tSchedefBoardRowIdx = 0, tSchedefBoardTpl = 'tSchedefBoardTpl';	
var tSchedefOffRowIdx = 0, tSchedefOffTpl = 'tSchedefOffTpl';	
var tSchedefVehiRowIdx = 0, tSchedefVehiTpl = 'tSchedefVehiTpl';
		$(document).ready(function() {
			//$("#name").focus();
			
			var citys = "";
			var dataBoard = ${fns:toJson(tSchedef.tSchedefBoardList)};
			for (var i=0; i<dataBoard.length; i++){
				addRow('#tSchedefBoardList', i, tSchedefBoardTpl, dataBoard[i] );
				citys = citys + dataBoard[i].citycode + ",";
			}
			
			var dataOff = ${fns:toJson(tSchedef.tSchedefOffList)};
			for (var i=0; i<dataOff.length; i++){
				addRow('#tSchedefOffList', i, tSchedefOffTpl, dataOff[i]);
				if (i == dataOff.length - 1)
					citys = citys + dataOff[i].citycode;
				else
					citys = citys + dataOff[i].citycode + ",";
			}
			
			var dataVehi = ${fns:toJson(tSchedef.tSchedefVehiList)};
			for (var i=0; i<dataVehi.length; i++){
				addRow('#tSchedefVehiList', i, tSchedefVehiTpl, dataVehi[i],citys);
			}
			var updateflag = $("#updateorview").val();
			
			//查看时应将所有控件禁用
			if (updateflag == "D"){
				$(":input").prop("disabled", true);
				$(":button").prop("disabled", true);
				$(":submit").prop("disabled", true);
				$("select").prop("disabled", true);
				$('.close').removeAttr('onclick');
			}
			
			$("#inputForm").validate({
			    rules: {
			    	departtypes: {haveto:true},
			    	settleprice: {compare:true},
			    	boardnum:{range:[1,10]},
			    	offnum:{range:[1,10]},
			    	schename: {remote: "${ctx}/schedef/tSchedef/checkSchename?oldSchename=" + encodeURIComponent('${tSchedef.schename}')}
			    },
			    messages:{
			    	departtypes: {haveto:'发车日期类型至少选择一个！'},
			    	boardnum: {range:'应至少添加一个上客点！'},
			    	offnum: {range:'应至少添加一个下客点！'},
			    	schename: {remote: "线路名称已存在"},
			    },
				submitHandler: function(form){
					
				var	Boardnum=$("#tSchedefBoardList tr").length;
				var	Offnum=$("#tSchedefOffList tr").length;
				var	Vehinum=$("#tSchedefVehiList tr").length;
				
				//判断集合时间是否按条件正确输入
				var lastOffList =Offnum -1;
				var offid= "#tSchedefOffList"+lastOffList+"_gathertime";
				var offidGathertime = $(offid).val();
				//得到班次类型的值
				var schetype = document.getElementById("schetype").value;
				if(schetype==3){
					if(offidGathertime.length!=0 ){
						alert("下客点最后集合时间不能输入值");
					}else{
						loading('正在提交，请稍等...');
						form.submit();
					}
				}else if(schetype==4){
					if(offidGathertime==""||offidGathertime==null||offidGathertime==undefined ){
						alert("下客点最后集合时间不能为空");
					}else{
						loading('正在提交，请稍等...');
						form.submit();
					}
				}
				else{
						loading('正在提交，请稍等...');
						form.submit();
				}
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		$.validator.addMethod("haveto", function(value, element) {
			var departtype = $('#departtype').val();
			if (departtype == "0_0_0_0_0_0_0_"){
				return false;
			}else{
				return true;
			}
		}, "发车日期类型至少选择一个！");
		$.validator.addMethod("compare", function(value, element) {
			var bigger = $('#retailprice').val();
			var smaller = $('#settleprice').val();
			if(parseInt(bigger)>=parseInt(smaller)){
				return true;
			} else {
				return false;
			}
		}, "分销价不能大于零售价");
		function addRow(list, idx, tpl, row, citys){
			//var datalist = {"list":row};
			var data;
			//根据班次类型进行上下客点选择
			var schetype = document.getElementById("schetype").value;

			if(row) { // 加载后台的有默认值
				data = {idx: idx, delBtn: true, row:row,schetype:schetype};
				if(list=="#tSchedefVehiList"){
					var num=$("#tSchedefVehiList tr").length;
					var prefix = list + num;
					
				 	rendercompany(citys, prefix, row.office.id);
				 	keypress(row.office.id, prefix, row.busid);
				 	keypresstwo(row.office.id, row.busid, prefix);		  
				}else
				if(list=="#tSchedefBoardList"){
					var num=$("#tSchedefBoardList tr").length;
					var prefix = list + num;	
					checkCode(row.citycode, prefix, 1, row.siteid);
				}else
				if(list=="#tSchedefOffList"){
					var num=$("#tSchedefOffList tr").length;
					var prefix = list + num;
					checkCode(row.citycode, prefix, 2, row.siteid);
				}	
			} else { 
				// 新增的是没有默认值的
				//获取当前动态行的行数
				//上客点
				var num;
				var count;
				var tmpcitys = "";
				if(list == "#tSchedefBoardList"){
					num = $("#tSchedefBoardList tr").length;
					count = num + 1;
					$("#boardnum").val(count);

				}
				//下客点
				if(list=="#tSchedefOffList"){
					num=$("#tSchedefOffList tr").length;
					count = num + 1;
					$("#offnum").val(count); 
				}
				//车辆
				if(list=="#tSchedefVehiList"){
					for (var i = 0; i < $("#boardnum").val(); i++){
						tmpcitys = tmpcitys+ $("#tSchedefBoardList"+i+"_citycode").val() + ",";	
					}
					for (var i = 0; i < $("#offnum").val(); i++){
						tmpcitys = tmpcitys+ $("#tSchedefOffList"+i+"_citycode").val() + ",";	
					}
					num=$("#tSchedefVehiList tr").length;
					var prefix = list + num;
					rendercompany(tmpcitys, prefix);
				}
				//console.log(num);
				data = {idx: num, delBtn: true,schetype:schetype};
			}
			 //查询保存的上下客点信息
	    	var html = template(tpl, data); // 渲染模板
	    	
			$(list).append(html);
			$(list+idx).find("select").each(function(){
				$(this).val($(this).attr("data-value"));
				$(this).find("option[selected='selected']").attr("selected",'selected'); 
			});
			if(list =="#tSchedefVehiList"){
				countSeats();
			}
			//data = {idx: num, delBtn: true};
			/* var tlineobj =document.getElementById("tline");
			var tlinevalue = tlineobj.options[tlineobj.selectedIndex].value;
			tlineChange(tlinevalue);  */
		} 
		 function delRow(obj, prefix, list){
				var id = $(prefix+"_id");
				//console.log(id);
				var delFlag = $(prefix+"_delFlag");
				if (id.val() == ""){
					$(obj).parent().parent().remove();
				}else if(delFlag.val() == 0){
					delFlag.val("1");
					$(obj).html("&divide;").attr("title", "撤销删除");
					$(obj).parent().parent().addClass("error");
				}else if(delFlag.val() == 1){
					delFlag.val("0");
					$(obj).html("&times;").attr("title", "删除");
					$(obj).parent().parent().removeClass("error");
				}
				var num;
				if(list=="#tSchedefBoardList"){
					num=$("#tSchedefBoardList tr").length;
					$("#boardnum").val(num); 
				}
				//下客点
				if(list=="#tSchedefOffList"){
					num=$("#tSchedefOffList tr").length;
					$("#offnum").val(num); 
				}
				//车辆
				if(list=="#tSchedefVehiList"){
					countSeats();
				}

			}
		 //计算车辆和车辆数
		function countSeats(){		
			// 车辆定义
			var sum = 0;
			var list = $('tbody[id=tSchedefVehiList] tr td input');
			var length = list.length;
			if(length>0) {
				var i=1;
				//计算座位数
				list.each(function(){
					if(this.name.indexOf("seats") >= 0){
						var single = this.value;
						if(typeof(single)!="undefined" && single!=''){
							sum += parseInt(single);
						}
					}
					i++;
				});
			}
			$('input[name=totalseats]').val(sum);
			$('input[name=vehiclenum]').val($('tbody[id=tSchedefVehiList] tr').length);	
		}
		//修改获取车辆型号
		function checkSelect(vehiclename){
			//<c:forEach items="${tSchedef.tSchedefVehiList}" var="item">
			if("${item.vehiclename}"==vehiclename){
				return true;
			}
			//</c:forEach>
			return false;
		}
		//修改获取上客点
		function checkBoardkStied(dataid, siteid){
			if(dataid==siteid){
				return true;
			}
			return false;
		}
		//修改获取下客点
		function checkOffdStied(dataid, siteid){
			if(dataid==siteid){
				return true;
			}
			return false;
		}
		function checkOffice(dataid, officeid){
			if(dataid==officeid){
				return true;
			}
			return false;
		}
		//通过选择城市显示上客点
		function checkCode(code,prefix,type,siteid){
			 var board = prefix + "_siteid";
			 var offd = prefix + "_siteid";
			 url = "${ctx}/schedef/tSchedef/ajaxStied";
			 $.ajax({
		          	dataType: 'json',
		            url:url,
		            data:{code:code},
		            type: 'POST',
		            success: function(data) {
		            	var obj = eval(data);
		            	var html = '';
		            	 //上客点显示
		            	if(type==1){ 
			            	$.each(obj, function (i, item) {
			            		  var select1 = checkBoardkStied(siteid,item.siteid)?"selected=selected":"";
			            		  html+="<option value='"+ item.siteid+"' "+select1+">"+ item.sitename+"</option>";
			            	}); 
			            	jQuery(board).html(html);
		            	 }      	  //下客点显示
		            	 else{
		            		$.each(obj, function (i, item) {
			              		  var select2 = checkOffdStied(siteid, item.siteid)?"selected=selected":'';
			            		  html+="<option value='"+ item.siteid+"' "+select2+">"+ item.sitename+"</option>";
			            	});
			            	jQuery(offd).html(html);
			            	console.log(html)
		            	 } 
		            },
		            error: function() {
		            		 alert("数据有误");
		            }
		        });     
		}
		//修改获取车辆车牌号
		function checkBusid(dataid, busid){
			if(dataid == busid){
				return true;
			}
			return false;
		}
		function rendercompany(citys,prefix,officeid) {
			var officehtml = prefix+"_office";
			url = "${ctx}/schedef/tSchedef/getOfficeByCitys";
			console.log({citys:citys})
			$.ajax({
				dataType: 'json',
				url:url,
				data:{citys:citys},
				type: 'POST',
				cache:false,
				success: function(data) {
					var obj = data;
					if(obj!=null){
						var html = '';
						var offices='';
						jQuery(officehtml).html('');
						$.each(obj, function (i, item) {
							var select = '';
							if (officeid != null){
								select = checkOffice(officeid, item.id)?"selected=selected":"";
							}
							else{
								select = "";
							}
							offices =  "<option value='"+'' +"' >"+ '--请选择--'+"</option>" ;
							html += "<option value='"+ item.id+"' "+select+">"+ item.name+"</option>";
						}); 
						var htmls = offices +html;
						jQuery(officehtml).html(htmls);
					}
				},
				error: function() {
					alert("数据有误");
				}
			});		
		}
		//通过选择客运公司显示车牌号
		function keypress(officeids,prefix, busid){			
			var busidhtml = prefix+"_busid";
			url = "${ctx}/schedef/tSchedef/ajaxVehiclename";
			 $.ajax({
		          dataType: 'json',
		            url:url,
		            data:{officeids:officeids},
		            type: 'POST',
		            cache:false,
		            success: function(data) {           	
		            	 var obj = eval(data);
		            	 var html = '';
		            	 var chus='';
		            	 jQuery(busidhtml).html('');
		            	 $.each(obj, function (i, item) {
		            		  var select = checkBusid(busid, item.busid)?"selected=selected":"";
		            		 // console.log(item.vehiclename)
		            		  //console.log('----'+select);
		            		chus=  "<option value='"+'' +"' >"+ '--请选择--'+"</option>" ;
		            		  html+=
		            			  "<option value='"+ item.busid+"' "+select+">"+ item.licenseno+"</option>";
		            			 
		            	  }); 
		            	  var htmls = chus +html;
		            	  console.log(htmls);
		            	  jQuery(busidhtml).html(htmls);
		            	 // console.log(html)
		            	countSeats();
		            	//keypresstwo(row.office.id, row.vehiclename,prefix);
		            },
		            error: function() {
		            		 alert("数据有误");
		            }
		        });     
		} 
		
		//通过汽车车牌号显示汽车信息
		function keypresstwo(officeids,busid,prefix){
			var vehiclename = prefix+"_vehiclename";
			var seats = prefix+"_seats";
			var maindriver = prefix+"_maindriver";
			
			url = "${ctx}/schedef/tSchedef/ajaxList";
			 $.ajax({
		          dataType: 'json',
		            url:url,
		            data:{officeids:officeids,busid:busid},
		            type: 'POST',
		            success: function(data) {
		            	console.log(data);
		            	 var obj = eval(data);
		            	
		            	 $(seats).val(obj[0].seatsforsale);
		            	 $(maindriver).val(obj[0].drvname);
		            	 $(vehiclename).val(obj[0].vehiclename);
		            	 
		            	/*  var html = '';
		            	 jQuery(licno).html('');
		            	  $.each(obj, function (i, item) {
		            		 //jQuery(licno).append("<option value="+ item.licenseno+">"+ item.licenseno+"</option>");
		            		  var select = checkLicenseno(item.licenseno)?"selected=selected":"";
		            		  html+="<option value='"+ item.licenseno+"' "+select+">"+ item.licenseno+"</option>";
		            		 }); 
		            	  jQuery(licno).html(html); */
		            	 countSeats();
		            },
		            error: function() {
		            		 alert("数据有误");
		            }
		        });     
		} 

		//通过发车日期类型的选择返回值
		 function change(){
			 var check = document.getElementsByName("departtypes");
			 var departtype = "";
			 
			 for(var i = 0; i<check.length; i++){
			    if(check[i].checked == true){
			       check[i].value = "1_";
			     }else{
			       check[i].value = "0_";
			    }
			    departtype= departtype+check[i].value;
			 }
			$('input[name=departtype]').val(departtype);
	    }
		
		//通过选中发车日期类型保存
		function changes() {
			var checks = document.getElementsByName("departtypes");
			var departtype = "";
			for(var i = 0; i<check.length; i++) {
				if(check[i].checked == false) {
					alert("请选择发车日期类型");
				}
			}
		}
		 $(function(){
			 //进入页面直接显示发车日期类型的值
			 var check = document.getElementsByName("departtypes");
			 var departtype = "";
			 for(var i = 0; i<check.length; i++){
			    if(check[i].checked == true){
			       check[i].value = "1_";
			     }else{
			       check[i].value = "0_";
			    }
			    departtype= departtype+check[i].value;
			 }
			$('input[name=departtype]').val(departtype);
            var schetype = '${tSchedef.schetype}';
 //           typeChange(schetype);
           
		})
		//通过班次类型判断显示上下客点内容
		function typeChange(values){
			//删除上下客点的数据
			boardnum=$("#tSchedefBoardList tr").length;
			for (var i = 0; i < boardnum; i ++)
				 $("#tSchedefBoardList"+i).remove();  
			$("#boardnum").val(0);
			//下客点
			offnum=$("#tSchedefOffList tr").length;
			for (i = 0; i < offnum; i ++)
				 $("#tSchedefOffList"+i).remove();  
			$("#offnum").val(0); 
			
		 }
		 
</script>
</head>
<body>

	<ul class="nav nav-tabs">
		<li><a href="${ctx}/schedef/tSchedef/modifylist">调度列表</a></li>
		 <c:choose>
		 <c:when test="${updateorview== 'M'}">
		<li class="active"><a
			href="${ctx}/schedef/tSchedef/form?id=${tSchedef.id}&updateorview=M">			
				<shiro:hasPermission name="schedef:tSchedef:edit">班次调度 </shiro:hasPermission>
		</a></li>
		</c:when>
		<c:when test="${updateorview== 'D'}">
		<li><a
			href="${ctx}/schedef/tSchedef/dispatchlist?id=${tSchedef.oriScheid}">历史调度
		</a></li>
		<li class="active"><a
			href="${ctx}/schedef/tSchedef/form?id=${tSchedef.id}&updateorview=D">			
				<shiro:hasPermission name="schedef:tSchedef:edit">调度详细 </shiro:hasPermission>
		</a></li>
		</c:when>
		</c:choose>
	</ul>
	<br />
	<input id="tSchedefVehiLists" name="tSchedefVehiLists" type="hidden"
		value="${fns:toJson(tSchedef.tSchedefVehiList)}" />
	<%-- <input type="hidden" id="tschedefb" name="tschedefb"
		value="${tSchedefBoardJson}"> --%>
	<form:form id="inputForm" modelAttribute="tSchedef"
		action="${ctx}/schedef/tSchedef/dispatch" method="post"
		class="form-horizontal">
		<form:hidden path="id" />
		<form:hidden path="departtype" />
		<input type="hidden" id="updateorview" name="updateorview"
			value="${updateorview}" />
		<sys:message content="${message}" />
		<div class="control-group">
			<label class="control-label">班次名称：</label>
			<div class="controls">
				<form:input path="schename" htmlEscape="false" maxlength="64"
					class="span4 required" readonly="true" />
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">班次类型：</label>
			<div class="controls">
				<form:select path="schetype" class="span4"
					onchange="typeChange(this.options[this.options.selectedIndex].value)" disabled="true">
					<form:options items="${fns:getDictList('T_Schede_Type')}"
						itemLabel="label" itemValue="value" htmlEscape="false" />
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">发车日期类型：</label>
			<div class="controls">
				<input type="checkbox" id="departtypes" name="departtypes"
					onchange="change()"
					<c:choose><c:when test="${departtypes1 eq 1 }">checked="true" value="1"</c:when><c:otherwise >value="0"</c:otherwise></c:choose> />周一
				<input type="checkbox" id="departtypes" name="departtypes"
					onchange="change()"
					<c:choose><c:when test="${departtypes2 eq 1 }">checked="true" value="1"</c:when><c:otherwise >value="0"</c:otherwise></c:choose> />周二
				<input type="checkbox" id="departtypes" name="departtypes"
					onchange="change()"
					<c:choose><c:when test="${departtypes3 eq 1 }">checked="true" value="1"</c:when><c:otherwise >value="0"</c:otherwise></c:choose> />周三
				<input type="checkbox" id="departtypes" name="departtypes"
					onchange="change()"
					<c:choose><c:when test="${departtypes4 eq 1 }">checked="true" value="1"</c:when><c:otherwise >value="0"</c:otherwise></c:choose> />周四
				<input type="checkbox" id="departtypes" name="departtypes"
					onchange="change()"
					<c:choose><c:when test="${departtypes5 eq 1 }">checked="true" value="1"</c:when><c:otherwise >value="0"</c:otherwise></c:choose> />周五
				<input type="checkbox" id="departtypes" name="departtypes"
					onchange="change()"
					<c:choose><c:when test="${departtypes6 eq 1 }">checked="true" value="1"</c:when><c:otherwise >value="0"</c:otherwise></c:choose> />周六
				<input type="checkbox" id="departtypes" name="departtypes"
					onchange="change()"
					<c:choose><c:when test="${departtypes7 eq 1 }">checked="true" value="1"</c:when><c:otherwise >value="0"</c:otherwise></c:choose> />周日
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">车辆数：</label>
			<div class="controls">
				<%-- <input type="hidden" id="vehiclenumDefault" value="${tSchedef.vehiclenum }"/> --%>
				<form:input path="vehiclenum" htmlEscape="false"
					class="span4 required" readonly="true" placeholder="定义车辆后自动显示" />
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">可售座位数：</label>
			<div class="controls">
				<form:input path="totalseats" htmlEscape="false"
					class="span4 required" readonly="true" placeholder="定义车辆后自动显示" />
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">预售天数：</label>
			<div class="controls">
				<form:input path="preselldate" htmlEscape="false" readonly="true"
					class="span4 required digits" value="90"
					onfocus="if(value=='90'){value=''}"
					onblur="if(value==''){value='90'}" />
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<!-- <div id="contentss"></div> -->
		<div class="control-group">
			<label class="control-label">上客点：</label>
			<div class="controls">
				<table id="contentTable"
					class="table table-striped table-bordered table-condensed">
					<thead>
						<tr>
							<th class="hide"></th>
							<!-- <th>defboardid</th> -->
							<th>城市</th>
							<th>上客地点</th>
							<th id="type2">零售价</th>
							<th id="type3">分销价</th>
							<th>上客时间</th>
							<shiro:hasPermission name="schedef:tSchedef:edit">
								<th width="10">&nbsp;</th>
							</shiro:hasPermission>
						</tr>
					</thead>
					<tbody id="tSchedefBoardList">

					</tbody>
					<shiro:hasPermission name="schedef:tSchedef:edit">
						<tfoot>
							<tr>
								<td colspan="6"><input
									onclick="addRow('#tSchedefBoardList', tSchedefBoardRowIdx, tSchedefBoardTpl);tSchedefBoardRowIdx = tSchedefBoardRowIdx + 1;"
									class="btn" type="button" value="新增"/> <span class="help-inline">共</span> <input
									class="span1" readonly="readonly" id="boardnum" name="boardnum"
									value="${boardnum}" /> <span class="help-inline">条</span></td>
							</tr>
						</tfoot>
					</shiro:hasPermission>
				</table>
				<script type="text/template" id="tSchedefBoardTpl">
					<tr id="tSchedefBoardList{{idx}}">
						<td class="hide">
							<input id="tSchedefBoardList{{idx}}_id"
							name="tSchedefBoardList[{{idx}}].id" type="hidden"
							{{if row}}value="{{row.id}}"{{/if}} />
							<input id="tSchedefBoardList{{idx}}_delFlag"
							name="tSchedefBoardList[{{idx}}].delFlag" type="hidden" value="0" />
						</td>
						<td>
<input id="tSchedefBoardList{{idx}}_citycode" name="tSchedefBoardList[{{idx}}].citycode" type="hidden" value="{{if row}}{{row.citycode}}{{/if}}"/>
<input id="tSchedefBoardList{{idx}}_cityname" name="tSchedefBoardList[{{idx}}].cityname" type="text" value="{{if row}}{{row.cityname}}{{/if}}" class="input-mini" onclick="showArea(this,'tSchedefBoardList{{idx}}_citycode','tSchedefBoardList{{idx}}_cityname','#tSchedefBoardList{{idx}}',1,'');"/>
								<!--<select id="tSchedefBoardList{{idx}}_citycode" name="tSchedefBoardList[{{idx}}].citycode" class="input-small" onchange="checkCode(this.options[this.options.selectedIndex].value,'#tSchedefBoardList{{idx}}',1,'')">  
  								<option value="">--请选择--</option>
								<c:forEach items="${tSitedList}" var="tSited">
  								<option value ="${tSited.citycode}"  {{if row}}{{if row.citycode == '${tSited.citycode}' }}selected="selected"{{/if}}{{/if}}>
  								${tSited.cityname}</option></c:forEach>  
							</select>	-->	
							</td>
						<td>
							<select id="tSchedefBoardList{{idx}}_siteid"
							name="tSchedefBoardList[{{idx}}].siteid" class="input-xxlarges">
							</select></td>
						<td>
							<input id="tSchedefBoardList{{idx}}_retailprice"
							name="tSchedefBoardList[{{idx}}].retailprice" type="text" {{if schetype == 1 || schetype == 2}}readonly="readonly" class="input-mini money"{{else}}class="input-mini required money"{{/if}}
							{{if row}}value="{{row.retailprice}}"{{/if}}  onchange="change()"/>
						</td>
						<td>
							<input id="tSchedefBoardList{{idx}}_settleprice"
							name="tSchedefBoardList[{{idx}}].settleprice" type="text" {{if schetype == 1 || schetype == 2}}readonly="readonly" class="input-mini money"{{else}}class="input-mini required money"{{/if}}
							{{if row}}value="{{row.settleprice}}"{{/if}}  onchange="change()"/>
						</td>
			 			<td>
							<select id="tSchedefBoardList{{idx}}_diffdays"
							name="tSchedefBoardList[{{idx}}].diffdays" type="text"
							  class="span1 required" {{if row}}value="{{row.diffdays}}"{{/if}}>
							<option value="0" {{if row}}{{if row.diffdays == 0 }}selected="selected"{{/if}}{{/if}}>当日</option>
							<option value="1" {{if row}}{{if row.diffdays == 1 }}selected="selected"{{/if}}{{/if}}>次日</option>
							<option value="2" {{if row}}{{if row.diffdays == 2 }}selected="selected"{{/if}}{{/if}}>后日</option>	
							<option value="3" {{if row}}{{if row.diffdays == 3 }}selected="selected"{{/if}}{{/if}}>四日</option>						
							</select>
							<input id="tSchedefBoardList{{idx}}_boardtime"
							name="tSchedefBoardList[{{idx}}].boardtime" type="text"
							readonly="readonly"
							class="input-mini Wdate required" {{if row}}value="{{row.boardtime}}"{{/if}}
							onclick="WdatePicker({dateFmt:'HH:mm',isShowClear:true});" /></td>
						<shiro:hasPermission name="schedef:tSchedef:edit"><td class="text-center" width="10">
								<span class="close" onclick="delRow(this, '#tSchedefBoardList{{idx}}', '#tSchedefBoardList')" title="删除">&times;</span>
							</td></shiro:hasPermission>
					</tr>
				</script>
				<script type="text/javascript">	

				</script>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">下客点：</label>
			<div class="controls">
				<table id="contentTable"
					class="table table-striped table-bordered table-condensed">
					<thead>
						<tr>
							<th class="hide"></th>
							<!-- <th>下客点序号</th> -->
							<th>城市</th>
							<th>下客地点</th>
							<th id="types2">零售价</th>
							<th id="types3">分销价</th>
							<th id="types4">集合时间</th>
							<shiro:hasPermission name="schedef:tSchedef:edit">
								<th width="10">&nbsp;</th>
							</shiro:hasPermission>
						</tr>
					</thead>
					<tbody id="tSchedefOffList">
					</tbody>
					<shiro:hasPermission name="schedef:tSchedef:edit">
						<tfoot>
							<tr>
								<td colspan="5"><input 
									onclick="addRow('#tSchedefOffList', tSchedefOffRowIdx, tSchedefOffTpl);tSchedefOffRowIdx = tSchedefOffRowIdx + 1;"
									class="btn" type="button" value="新增"/> <span class="help-inline">共</span> <input
									class="span1" id="offnum" name="offnum" readonly="readonly"
									value="${offnum}" /> <span class="help-inline">条</span></td>
							</tr>
						</tfoot>
					</shiro:hasPermission>
				</table>
				<script type="text/template" id="tSchedefOffTpl">

						<tr id="tSchedefOffList{{idx}}">
							<td class="hide">
								<input id="tSchedefOffList{{idx}}_id" name="tSchedefOffList[{{idx}}].id" type="hidden" {{if row}}value="{{row.id}}"{{/if}} />
								<input id="tSchedefOffList{{idx}}_delFlag" name="tSchedefOffList[{{idx}}].delFlag" type="hidden" value="0"/>
							</td>
							<td>
<input id="tSchedefOffList{{idx}}_citycode" name="tSchedefOffList[{{idx}}].citycode" type="hidden" value="{{if row}}{{row.citycode}}{{/if}}"/>
<input id="tSchedefOffList{{idx}}_cityname" name="tSchedefOffList[{{idx}}].cityname" type="text" value="{{if row}}{{row.cityname}}{{/if}}" class="input-mini" onclick="showArea(this,'tSchedefOffList{{idx}}_citycode','tSchedefOffList{{idx}}_cityname','#tSchedefOffList{{idx}}',1,'');"/>
							</td>
							<td>
								<select id="tSchedefOffList{{idx}}_siteid" name="tSchedefOffList[{{idx}}].siteid" class="input-xxlarges" >  
								</select>
							</td>

							  <td>
								<input id="tSchedefOffList{{idx}}_retailprice"
								name="tSchedefOffList[{{idx}}].retailprice" type="text" class="input-mini required money" 
								{{if row}}value="{{row.retailprice}}"{{/if}}  />
							</td>
						    <td>
								<input id="tSchedefOffList{{idx}}_settleprice"
								name="tSchedefOffList[{{idx}}].settleprice" type="text" class="input-mini required money"
								{{if row}}value="{{row.settleprice}}"{{/if}}  />
						    </td>					
						<td>
							<select id="tSchedefOffList{{idx}}_diffdays"
							name="tSchedefOffList{{idx}}].diffdays" type="text"
							{{if schetype ==1}}disabled="disabled"{{/if}} class="span1 required" {{if row}}value="{{row.diffdays}}"{{/if}}>
							{{if schetype ==2}}
							<option value="0" {{if row}}{{if row.diffdays == 0 }}selected="selected"{{/if}}{{/if}}>当日</option>
							<option value="1" {{if row}}{{if row.diffdays == 1 }}selected="selected"{{/if}}{{/if}}>次日</option>
							<option value="2" {{if row}}{{if row.diffdays == 2 }}selected="selected"{{/if}}{{/if}}>后日</option>	
							<option value="3" {{if row}}{{if row.diffdays == 3 }}selected="selected"{{/if}}{{/if}}>四日</option>	
							{{/if}}					
							</select>
								<input id="tSchedefOffList{{idx}}_gathertime"
								name="tSchedefOffList[{{idx}}].gathertime" type="text"
								readonly="readonly" maxlength="20" {{if schetype ==1}}disabled="true"{{/if}}
								class="input-mini Wdate " {{if row}}value="{{row.gathertime}}"{{/if}}
								onclick="WdatePicker({dateFmt:'HH:mm',isShowClear:true});" /></td>

							<shiro:hasPermission name="schedef:tSchedef:edit"><td class="text-center" width="10">
								<span class="close" onclick="delRow(this, '#tSchedefOffList{{idx}}','#tSchedefOffList')" title="删除">&times;</span>
							</td></shiro:hasPermission>
						</tr>
					</script>
				<script type="text/javascript">

					</script>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">车辆：</label>
			<div class="controls">
				<table id="contentTable"
					class="table table-striped table-bordered table-condensed">
					<thead>
						<tr>
							<th class="hide"></th>
							<th>客运公司</th>
							<th>车牌号</th>
							<th>车型名称</th>
							<th>主司机</th>
							<th>可售座位数</th>
							<!-- <th>驾驶员</th> -->
							<shiro:hasPermission name="schedef:tSchedef:edit">
								<th width="10">&nbsp;</th>
							</shiro:hasPermission>
						</tr>
					</thead>
					<tbody id="tSchedefVehiList">
					</tbody>
					<shiro:hasPermission name="schedef:tSchedef:edit">
						<tfoot>
							<tr>
								<td colspan="8"><input 
									onclick="addRow('#tSchedefVehiList', tSchedefVehiRowIdx, tSchedefVehiTpl);tSchedefVehiRowIdx = tSchedefVehiRowIdx + 1;"
									class="btn" type="button" value="新增"/></td>
							</tr>
						</tfoot>
					</shiro:hasPermission>
				</table>
				<script type="text/template" id="tSchedefVehiTpl">
						<tr id="tSchedefVehiList{{idx}}">
							<td class="hide">
								<input id="tSchedefVehiList{{idx}}_id" name="tSchedefVehiList[{{idx}}].id" type="hidden" {{if row}}value="{{row.id}}"{{/if}}/>
								<input id="tSchedefVehiList{{idx}}_delFlag" name="tSchedefVehiList[{{idx}}].delFlag" type="hidden" value="0"/>
							</td>
							<td>
								<select id="tSchedefVehiList{{idx}}_office" name="tSchedefVehiList[{{idx}}].office" class="input-medium required"  onchange="keypress(this.options[this.options.selectedIndex].value,'#tSchedefVehiList{{idx}}')"></select>
							</select>		
							</td>
							<td>
								<select id="tSchedefVehiList{{idx}}_busid" name="tSchedefVehiList[{{idx}}].busid" class="input-xxlarges required" onchange="keypresstwo(tSchedefVehiList{{idx}}_office.options[tSchedefVehiList{{idx}}_office.options.selectedIndex].value,this.options[this.options.selectedIndex].value,'#tSchedefVehiList{{idx}}')"></select>	  
							</td>
							<td>
								<input id="tSchedefVehiList{{idx}}_vehiclename" name="tSchedefVehiList[{{idx}}].vehiclename" type="text" {{if row}}value="{{row.vehiclename}}"{{/if}} maxlength="50" class="input-small required" readonly/>
							</td>
							<td>
								<input id="tSchedefVehiList{{idx}}_maindriver" name="tSchedefVehiList[{{idx}}].maindriver" type="text" {{if row}}value="{{row.maindriver}}"{{/if}} maxlength="50" class="input-small required" readonly/>
							</td>
							
							<td>
								<input id="tSchedefVehiList{{idx}}_seats" name="tSchedefVehiList[{{idx}}].seats" type="text" {{if row}}value="{{row.seats}}"{{/if}} class="input-small required" readonly/>
							</td>
							<shiro:hasPermission name="schedef:tSchedef:edit"><td class="text-center" width="10">
								<span class="close" onclick="delRow(this, '#tSchedefVehiList{{idx}}','#tSchedefVehiList')" title="删除">&times;</span>
							</td></shiro:hasPermission>
						</tr>
					</script>
				<script type="text/javascript">

					</script>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">调整班次：</label>
			<div class="controls">
			
				<input type="text" id="startDate" name="startDate" maxlength="20" readonly
					class="span4 Wdate required" value="${tSchedef.startDate}"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true,minDate:'${tomorrow}'});" />
			</div>
			<label class="control-label">至：</label>
			<div class="controls">
				<input id="endDate" name="endDate" type="text" readonly="readonly"
					maxlength="20" class="span4 Wdate required" 
					value="${tSchedef.endDate}"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true,minDate:'${tomorrow}'});" />
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="schedef:tSchedef:edit">
				<input id="btnSubmit" class="btn btn-primary" type="submit"
					value="保 存" />&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回"
				onclick="history.go(-1)" />
		</div>
	</form:form>

</body>
<script type="text/javascript">
 
</script>
</html>